{php $toupiaoyonghu = '1_'.MOD_DIR.'_toupiaobiao';}
{count action=table table=$toupiaoyonghu cid=$id return=tp}

<div class="d-kuan d-shang-15">
	<div class="d-kuan d-wenzi-juzhong   "> 已投</span> <span class="d-wenzi-18 d-zitiyanse-hongse">{$tp_count}</span> <span class="ziti-10 huise-10">票</span></div>
	{if $toupiaomoshi == 1}
	    <div class="d-kuan d-wenzi-juzhong d-wenzi-18 d-zitiyanse-hongse d-jiacu"> 单选投票</div>
	{else}
	   <div class="d-kuan d-wenzi-juzhong d-wenzi-18 d-zitiyanse-hongse d-jiacu"> 多选投票</div>
	{/if}
	<div class="d-kuan d-wenzi-juzhong d-wenzi-14 d-zitiyanse-hongse ">
		
		{if strtotime($ptjssj) < time()}
			投票活动已经结束
		{else}
		    结束： {$ptjssj} 
		{/if}
	</div>
	{if $tpzsfs ==1}
		{loop $tpxm $i $v}
			{count action=table table=$toupiaoyonghu cid=$id  toupiaoid=$i return=tptongji}
			<div class="d-kuan d-xian-1 d-shang-15 d-yuanjiao-10 d-beijing-hui d-neikuang-10">
				{$i}. {$v[1]}
				<div class="d-yuanjiao-20 d-kuan d-buhuanhang d-a-hei">
					{if $tptongji_count > 0}
					<div class="d-yuanjiao-20 d-kuan d-buhuanhang d-a-hei">
						<div class="d-zitiyanse-hui-ca pull-left d-you-10" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" onclick="javascript:d_toupiao_yonghu({$i},{$id});"><i class="fa fa-user"></i> </div>
						{table table=$toupiaoyonghu toupiaoid=$i cid=$id order=inputtime_desc num=15 return=tp2}
							<a href="/index.php?s=huiyuan&c=show&m=index&uid={$tp2.uid}" class="d-touxiang-30-0">
								<img src="{dr_avatar($tp2.uid)}" class=" d-yuanjiao-50"  width="25" height="25"/>
							</a>
						{/table}
					
					</div>
					{/if}
				</div>
				
				<div class="d-kuan d-buhuanhang">
					<div class="d-kuan ">
						<div class="progress d-shang-10 d-xia-10 ">
							{if $tp_count >0}
							{php $tj = ($tptongji_count / $tp_count)*100;}
							{else}
							{php $tj = 0;}
							{/if}
							<div class="progress-bar " role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:{$tj}%">
							{$tptongji_count}
							</div>
						</div>
					</div>
					{if strtotime($ptjssj) < time()}
    					<div class="d-kuan-70 d-shang-4">
    						<div class="d-kuan">
    							<div class="zuo-5 ziti-18 pull-right you-1 wenzihongse a hanggai-12 d-quxian-0" >
    								<a class="wenzihongse d-zitiyanse-hongse" >结束</a>
    							</div>
    						</div>
    					</div>
					{else}
            		    {php $yitou = \Phpcmf\Service::M()->db->table($toupiaoyonghu)->where('cid', $id)->where('leixing', 1)->where('uid', $member.id)->where('toupiaoid', $i)->get()->getRowArray();}
            		    {if $yitou}
        					<div class="d-kuan-70 d-shang-4">
        						<div class="d-kuan">
        							<div class="zuo-5 ziti-18 pull-right you-1 wenzihongse a hanggai-12 d-quxian-0" >
        								<a class="wenzihongse d-toupiao  tag_toupiaom_{$id}_{$i}" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" style="color:#5086ff">已投</a>
        							</div>
        						</div>
        					</div>
        				{else}
        				<div class="d-kuan-70 d-shang-4">
        						<div class="d-kuan">
        							<div class="zuo-5 ziti-18 pull-right you-1 wenzihongse a hanggai-12 d-quxian-0" >
        								<a class="wenzihongse d-toupiao d-zitiyanse-hongse tag_toupiaom_{$id}_{$i}" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" >投票</a>
        							</div>
        						</div>
        					</div>
        				{/if}
            		{/if}
				</div>
			</div>
			
		{/loop}
		{loop $tpxm $i $v}
		    <!--投票用户-->
		    {count action=table table=$toupiaoyonghu cid=$id  toupiaoid=$i return=tptongji}
		    {if $tptongji_count > 0}
		    <div class="d-xiala-toupiao-yonghu d-toupiao-yonghu{$i}" style="display: none;">
		    	<div class="d-container">
		    		<div class="d-row">
		    			<div class="d-col-md-8-juzhong d-quxian-0 d-a-baise">
		    				<div class="d-neikuang-15 ">
		    					<div class="d-kuan d-neikuang-10" onclick="javascript:d_toupiao_yonghu({$i},{$id});"><i class="bi bi-x-circle-fill"></i></div>
		    				</div>
		    				{table table=$toupiaoyonghu toupiaoid=$i cid=$id order=inputtime_desc num=15 return=tp2}
		    				{php $user=dr_member_info($tp2.uid);} 
		    				<div class="d-kuan d-neikuang-5-10 d-buhuanhang d-wenzi-12">
		    					
		    					<div class="d-img-20">
		    						<a href="/index.php?s=huiyuan&c=show&m=index&uid={$tp2.uid}" class="d-touxiang-20-0 d-img-20">
		    							<img src="{dr_avatar($tp2.uid)}" class=" d-yuanjiao-50" width="16" height="16"/>
		    						</a>
		    					</div>
		    					<div class="d-zuo-10">
		    						投票号：{$tp2.id}
		    					</div>
		    					<div class="d-zuo-10">
		    						{$user.username}
		    					</div>
		    				</div>
		    				{/table}
		    				
		    			</div>
		    		</div>
		    	</div>
		    </div>
		    {/if}
		{/loop}
	{else}
	<div class="row d-shang-15">
		<div class="" id="toupiaozu">
		{loop $tpxm $i $v}
		<div class="col-md-4 col-xs-4 liebiaotu-zhong d-yuanjiao-10 xia-20 a">
			<img src="{dr_get_file($v[2])}" class="d-yuanjiao-10"/>
			{count action=table table=$toupiaoyonghu cid=$id  toupiaoid=$i return=tptongji}
			
			<div class="d-kuan d-xian-1 d-shang-15 d-yuanjiao-10 d-beijing-hui d-neikuang-10">
				{$i}. {$v[1]}
				
				
				<div class="d-kuan ">
					<div class="d-kuan ">
						<div class="progress d-shang-10 d-xia-10 ">
							
							{if $tp_count >0}
							{php $tj = ($tptongji_count / $tp_count)*100;}
							{else}
							{php $tj = 0;}
							{/if}
							<div class="progress-bar " role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:{$tj}%">
							{$tptongji_count}
							</div>
						</div>
					</div>
					<div class="d-shang-4">
					{if strtotime($ptjssj) < time()}
					    <div class="d-kuan">
							<div class="d-wenzi-juzhong">
								
								<a class="wenzihongse d-zitiyanse-hongse">结束</a>
							</div>
						</div>
						
					{else}
					    {if $tptongji_count > 0}
						<div class="d-kuan">
								<a class="d-zitiyanse-hui-ca pull-left" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" onclick="javascript:d_toupiao_yonghu({$i},{$id});"><i class="fa fa-user"></i></a>
								<a class="wenzihongse d-toupiao d-zitiyanse-hongse pull-right tag_toupiaom_{$id}_{$i}" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" >投票</a>
						</div>
						{else}
    						{php $yitou = \Phpcmf\Service::M()->db->table($toupiaoyonghu)->where('cid', $id)->where('leixing', 1)->where('uid', $member.id)->where('toupiaoid', $i)->get()->getRowArray();}
    						{if $yitou}
    						<div class="d-kuan">
    							<div class="d-wenzi-juzhong">
    								
    								<a class="wenzihongse d-toupiao d-zitiyanse-hongse tag_toupiaom_{$id}_{$i}" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" style="color:#5086ff">已投</a>
    							</div>
    						</div>
    						{else}
    						<div class="d-kuan">
    							<div class="d-wenzi-juzhong">
    								
    								<a class="wenzihongse d-toupiao d-zitiyanse-hongse tag_toupiaom_{$id}_{$i}" id="tag_toupiao_{$id}_{$i}" data-id="{$id}" data-value="{$i}" >投票</a>
    							</div>
    						</div>
    						{/if}
						{/if}
					{/if}
					</div>
				</div>
				<div class="d-clear"></div>
			</div>
		</div>
		<!---->
			
		<!---->
		{/loop}
		</div>
		{loop $tpxm $i $v}
		    <!--投票用户-->
		    {count action=table table=$toupiaoyonghu cid=$id  toupiaoid=$i return=tptongji}
		    {if $tptongji_count > 0}
		    <div class="d-xiala-toupiao-yonghu d-toupiao-yonghu{$i}" style="display: none;">
		    	<div class="d-container">
		    		<div class="d-row">
		    			<div class="d-col-md-8-juzhong d-quxian-0 d-a-baise">
		    				<div class="d-neikuang-15 ">
		    					<div class="d-kuan d-neikuang-10" onclick="javascript:d_toupiao_yonghu({$i},{$id});"><i class="bi bi-x-circle-fill"></i></div>
		    				</div>
		    				{table table=$toupiaoyonghu toupiaoid=$i cid=$id order=inputtime_desc num=15 return=tp2}
		    				{php $user=dr_member_info($tp2.uid);} 
		    				<div class="d-kuan d-neikuang-5-10 d-buhuanhang d-wenzi-12">
		    					
		    					<div class="d-img-20">
		    						<a href="/index.php?s=huiyuan&c=show&m=index&uid={$tp2.uid}" class="d-touxiang-20-0 d-img-20">
		    							<img src="{dr_avatar($tp2.uid)}" class=" d-yuanjiao-50" width="16" height="16"/>
		    						</a>
		    					</div>
		    					<div class="d-zuo-10">
		    						投票号：{$tp2.id}
		    					</div>
		    					<div class="d-zuo-10">
		    						{$user.username}
		    					</div>
		    				</div>
		    				{/table}
		    				
		    			</div>
		    		</div>
		    	</div>
		    </div>
		    {/if}
		{/loop}
		</div>
		
	{/if}
</div>

<style>
	.d-beijingyanse-hong {
		background-color: #fff6f6;
		border-radius: 10px !important;
	}
	.xia-20 {
		margin-bottom: 20px;
		
	}
	.progress {
	    height: 12px;
	    background-color: #ededed;
	    border-radius: 50px;
	}
	.progress-bar {
	    float: left;
	    width: 0;
	    height: 100%;
	    font-size: 12px;
	    line-height: 12px;
	    color: #fff;
	    background-color: #f85f05;
	    -webkit-box-shadow: inset 0 -1px 0 rgba(255,255,255,.15);
	    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
	    -webkit-transition: width .6s ease;
	    -o-transition: width .6s ease;
	    transition: width .6s ease;
	}
	.d-beijing-hui {
	    background-color: #f9f9f9;
	}
	.d-touxiang-30-0 {
	    margin-right: -10px;
	    /*background-color: #ffffff;*/
	    border-radius: 50px;
	    /*box-shadow: 0 -3px 6px rgb(0 0 0 / 100%);*/
		
	    
	}
	.d-touxiang-30-0 img{
	    max-width: 100%;
	    margin-bottom: 0px;
	    background-color: #ffffff;
		border: 2px solid #ffffff;
		width: 25px;
	}
	.d-xiala-toupiao-yonghu {
	    z-index: 999999;
	    position: fixed;
	    bottom: 0px;
	    width: 100%;
	    height: 70%;
	    overflow: auto;
	    background: #ffffff;
	    right: 0;
	    left: 0;
	    box-shadow: 0 0 20px #d6d6d6;
	    background-color: rgba(255, 255, 255, 1.0);
	}
</style>
<script>
	//投票用户
	function d_toupiao_yonghu(i,id) {
		if ($('.d-toupiao-yonghu'+i).is(':hidden')) {
			$('.d-toupiao-yonghu'+i).show();
		} else {
			$('.d-toupiao-yonghu'+i).hide();
		}
	}
	// 单选拖漂
	$(".d-toupiao").click(function(){
			 var id = $(this).data("id");
			 var value = $(this).data("value");
			 $.get("{dr_url_prefix('index.php')}?s={MOD_DIR}&c=son&m=toupiao&id="+id+"&value="+value, function(data){
				 dr_cmf_tips(data.code, data.msg.value + data.msg.jifen);
				 
				 if (data.msg.value=="投票成功") {
					 $('#d_jindu_'+id).html('<i class="fa fa-hourglass-start"></i>'
					);
					//setTimeout("window.location.reload()",1000);
					var selector ='.tag_toupiaom_'+id+'_'+value;
					$(selector).each(function(index) {  
                            // 使用index变量来确保每个元素的文本都是唯一的  
                            // 使用text()方法来更改元素的文本内容  
                            $(this).text('已投');  
                    });
				}else if (data.msg.value=="您已经投票"){
					
					$('#d_jindu_'+id).html('<i class="fa fa-hourglass-o"></i>');

				} else if (data.msg.value=="取消投票"){
				    var selector ='.tag_toupiaom_'+id+'_'+value;
				    $(selector).each(function(index) {  
                            // 使用index变量来确保每个元素的文本都是唯一的  
                            // 使用text()方法来更改元素的文本内容  
                            $(this).text('投票');  
                    });
					
					//setTimeout("window.location.reload()",1000);

				} else {
					//window.location.reload();
				}
				
			 }, 'json');
	});
	var viewerzu = new Viewer(document.getElementById('toupiaozu'), {
	  	//url: 'data-kujue',
		toolbar: false,//关闭工具栏
		title: false,//关闭标题栏
		backdrop: true, //点击遮罩层不关闭
		rotatable: false, //图片是否可旋转
		scalable: false, //图片是否可翻转
		tooltip: false, //显示缩放百分比
	  });
</script>